using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace MIMPGameLibrary
{
    /// <summary>
    /// A Player object represents one of the people or AIs playing MIMP.
    /// </summary>
    [Serializable]
    public class Player
    {
        private string name;
        /// <summary>
        /// Gets or sets the name of the Player.
        /// </summary>
        public string Name {
            get { return name; }
            set { name = value; }
        }
        private Color color;
        /// <summary>
        /// The Color associated with this player.
        /// </summary>
        public Color Color {
            get { return color; }
            set { color = value; }
        }
        /// <summary>
        /// A List of all the Monsters under this Player's control.
        /// </summary>
        private List<Monster> _Monsters;
        /// <summary>
        /// Gets the list of Monsters controlled by the Player.
        /// </summary>
        public List<Monster> Monsters {
            get { return _Monsters; }
        }
        private int points;
        /// <summary>
        /// Gets or sets the number of deployment points the Player has remanining.
        /// </summary>
        public int DeploymentPoints {
            get { return points; }
            set { points = value; }
        }
        /// <summary>
        /// Constructs a new Player with specified name.
        /// </summary>
        /// <param name="name">The name of this player.</param>
        /// <param name="color">The color of this player.</param>
        /// <param name="points">The number of Deployment Points alloted to this Player.</param>
        public Player(string name, Color color, int points) {
            _Monsters = new List<Monster>();
            this.name = name;
            this.color = color;
            this.points = points;
        }

        public Player(string name) : this(name, Color.White, 0) { }

        /// <summary>
        /// False if all the Player's Monsters have health 0 or less; true otherwise.
        /// </summary>
        public bool hasLiveMonsters {
            get {
                foreach (Monster m in _Monsters) {
                    if (m.IsAlive) { return true; }
                }
                return false;
            }
        }

        public override string ToString() {
            return name;
        }
    }
}
